package model

import (
	"time"
)

// swagger:model Attachments
type Attachments struct {
	// swagger:allOf
	AttachmentsCreatable `xorm:"extends"`
	Id                   int64    `json:"id" xorm:"notnull pk autoincr BIGINT"`
	Status               byte      `json:"status" xorm:"TINYINT notnull default 1 comment('状态 -1:删除 0:禁用 1:正常')"`
	Created              time.Time `json:"created" xorm:"created TIMESTAMP notnull"`
	Updated              time.Time `json:"updated" xorm:"updated TIMESTAMP"`
}

// swagger:model AttachmentsCreatable
type AttachmentsCreatable struct {
	AppsId uint `json:"apps_id" xorm:"INT notnull comment('app id') index"`
	// 资源路径
	Url string `json:"url" xorm:"TEXT notnull comment('资源路径')"`
	// mime类型
	Mime string `json:"mime" xorm:"VARCHAR(32) notnull comment('mime类型')"`
	// 文件大小
	Size int64 `json:"size" xorm:"INT notnull comment('文件大小 size/1024/1024 = mb')"`
	// 文件sha1值
	Sha1 string `json:"sha1" xorm:"VARCHAR(64) notnull index comment('文件sha1值')"`
}

func (c Attachments) TableName() string {
	return "attachments"
}
